# 给出一个32位有符号整数，将每位上的数字进行反转

num1 = 123
num2 = -123
num3 = 120

# 每循环整除10的i次方并取余数，倒序之后再依次乘以10的i次方

def reversenum(nums):
    if nums > 2**31-1 or nums < (-2)**31:
        print(0)
    elif nums<0:
        nums = abs(nums)
        absv = -1
    else:
        absv = 1
    l = []
    for i in range(len(str(nums))):
        m = (nums//(10**i))%10
        l.append(m)
    lenl = len(l)
    total = 0
    for j in range(len(l)):
        lenl -= 1
        n = l[j]*(10**lenl)
        total += n
    print(total*absv)

reversenum(num1)
reversenum(num2)
reversenum(num3)
